class Solution {
public:
    void rotate(vector<vector<int>>& matrix) {
        int row = matrix.size();
        int col = matrix[0].size();
        int m = (row + 1) / 2;
        int n = col / 2;

        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
            {
                int tmp = matrix[i][j];

                matrix[i][j] = matrix[row - 1 - j][i];
                matrix[row - 1 - j][i] = matrix[row - 1 - i][col - 1 - j];
                matrix[row - 1 - i][col - 1 - j] = matrix[j][col - 1 - i];
                matrix[j][col - 1 - i] = tmp;
            }
    }
};